//
//  AY_ThinkCell.m
//  AiYue
//
//  Created by mac on 2023/11/9.
//

#import "AY_ThinkCell.h"

@interface AY_ThinkCell ()

@property (nonatomic, strong) UIImageView *icon;
@property (nonatomic, strong) UILabel *bookName;

@end

@implementation AY_ThinkCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self)
    {
        self.icon = [AYTool createImageViewWithFrame:CGRectZero andImage:YImage(@"AY_search_icon") andBg:nil andRadius:0 andAddSubView:self.contentView];
        [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(YNUM(16));
            make.centerY.equalTo(self.contentView);
            make.width.height.mas_equalTo(YNUM(16));
        }];
        
        self.bookName = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:COLOR(@"333333") andBgColor:nil andFont:YFont(15) andLines:1 andRadius:0 andAddSubView:self.contentView];
        [self.bookName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.icon.mas_right).offset(YNUM(10));
            make.centerY.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)sendTitle:(NSString *)title andThinkKey:(NSString *)thinkKey {
    self.bookName.text = title;
    NSRange range = [self.bookName.text rangeOfString:thinkKey];
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.bookName.text];
    [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:range];
    self.bookName.attributedText = attributedString;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
